import request from '@/utils/request'

// 查询消息列表
export function listMessage(query) {
  return request({
    url: '/message/list',
    method: 'get',
    params: query
  })
}

// 查询发送人消息详细
export function getFromMessage(fromId) {
  return request({
    url: '/message/from/' + fromId,
    method: 'get'
  })
}
// 查询接收人消息详细
export function getToMessage(toId) {
  return request({
    url: '/message/to/' + toId,
    method: 'get'
  })
}
// 查询消息详细
export function getMessage(messageId) {
  return request({
    url: '/message/' + messageId,
    method: 'get'
  })
}

// 新增消息
export function addMessage(data) {
  return request({
    url: '/message',
    method: 'post',
    data: data
  })
}

// 修改消息
export function updateMessage(data) {
  return request({
    url: '/message',
    method: 'put',
    data: data
  })
}
export function updateMessageReadStatus(messageId, readStatus) {
  const data = {
    messageId,
    readStatus
  }
  return request({
    url: '/message/updateReadStatus',
    method: 'put',
    data: data
  })
}

// 消息状态修改
export function updateMessageStatus(messageId, status) {
  const data = {
    messageId,
    status
  }
  return request({
    url: '/message/updateStatus',
    method: 'put',
    data: data
  })
}

// 删除消息
export function delMessage(messageId) {
  return request({
    url: '/message/' + messageId,
    method: 'delete'
  })
}
export function delMessageReadStatus0(messageId) {
  return request({
    url: '/message/readStatus0/' + messageId,
    method: 'delete'
  })
}
export function delMessageReadStatus1(messageId) {
  return request({
    url: '/message/readStatus1/' + messageId,
    method: 'delete'
  })
}
